import jwt

class JWTE:
    def __init__(self):
        self.secret_key='swdfghjk'
    # 加密
    def jia_secret(self,data):
        token=jwt.encode(data,self.secret_key,algorithm="HS256")
        return token
    # 解密
    def jie_secret(self,token):
        payload=jwt.decode(token,self.secret_key,algorithms=['HS256'])
        return payload
    # 对比
    def check_secret(self,token):
        payload = jwt.decode(token, self.secret_key, algorithms=['HS256'])
        token2 = jwt.encode(payload, self.secret_key, algorithm="HS256")
        if token2==token:
            return True
        else:
            return False

jwta=JWTE()
